package com.smartleanx.module.hrm.api.employee;

import com.smartleanx.framework.common.pojo.CommonResult;
import com.smartleanx.framework.common.util.object.BeanUtils;
import com.smartleanx.module.hrm.api.employee.dto.EmployeeInfoRespDto;
import com.smartleanx.module.hrm.controller.admin.employee.vo.EmployeeBasicInfoRespVo;
import com.smartleanx.module.hrm.dal.dataobject.employee.EmployeeDO;
import com.smartleanx.module.hrm.service.employee.EmployeeService;
import com.smartleanx.module.hrm.service.esign.auth.IElecCorpService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class EmployeeImplApi implements EmployeeApi {
    @Resource
    private EmployeeService employeeService;

    @Resource
    private IElecCorpService elecCorpService;
    @Override
    public CommonResult<List<EmployeeInfoRespDto>> getEmployeeInfo(Collection<Long> ids) {
        List<EmployeeBasicInfoRespVo> list = employeeService.getEmployeeInfoByIds(ids);
        return CommonResult.success(BeanUtils.toBean(list, EmployeeInfoRespDto.class));
    }

    @Override
    public CommonResult<EmployeeInfoRespDto> getByIda( Long id) {
        EmployeeDO employeeByUserId = employeeService.getEmployeeByUserId(id);

        return CommonResult.success(BeanUtils.toBean(employeeByUserId, EmployeeInfoRespDto.class));
    }


}
